﻿using INTEX.DataBase;
using INTEX.DataBase.Tools;
using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.Collections.Generic;
using System.Data;
using System.Windows;
using System.Windows.Input;
using System.Windows.Data;
using System.Windows.Controls;
using System.Windows.Media.Media3D;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for SummaryForm.xaml
    /// </summary>
    /// 
    public partial class TDBAB
    {
         
        ITXEXRPT ITXEXRPT;
       
        ITXABPLANData m_Data; 
       

        string WTYPE
        {
            get
            {
                if (cbWTYE.Text == "生产单")
                    return "V";
                if (cbWTYE.Text == "销售单")
                    return "K";
                if (cbWTYE.Text == "发货单")
                    return "L";
                return "V";
            }
        }
     
      
        #region Events
      

    
        #endregion
        public TDBAB()
        {
            MV = new VICC_QUERYTB();
            this.DataContext = MV;
            InitializeComponent();
            this.Name = "生产单查询";
            KRS = "88";
            LFD = "000101";
            POS = "001";
        }
      
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            Set.Merge(c11.TBMain);
            Set.Merge(c12.TBMain);
            Set.Merge(c13.TBMain);
            Set.Merge(c21.TBMain);
            Set.Merge(c22.TBMain);
            Set.Merge(c31.TBMain);
            Set.Merge(c32.TBMain);
            Set.Merge(c33.TBMain);
            KEY = "";
            KEY = KRS + LFD;
            base.QueryCommand(sender, e);
        } 
        private void btnRefreshStamm_Click(object sender, RoutedEventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnRefreshStock_Click(object sender, RoutedEventArgs e)
        {
            try
            {

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void btnRefreshGS07_Click(object sender, RoutedEventArgs e)
        {
            try
            {
              m_Data.CheckGSDAT();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void btnRefreshWS05_Click(object sender, RoutedEventArgs e)
        {
            try
            {
              m_Data.CheckWASTAMM();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

      
        private void btnDeleteABON_Click(object sender, RoutedEventArgs e)
        {
            //m_Data.DeleteABON(KRS, LFD, POS);
            m_Data.DeleteAV95(KRS, LFD, POS);
        }
        private void btnDeleteAB_Click(object sender, RoutedEventArgs e)
        {
            m_Data.Delete("00", KRS, LFD, POS);
        }

        private void PrintCommand(object sender, EventArgs e)
        {
            if (ITXEXRPT == null)
            {
                ITXEXRPT = new ITXEXRPT();
                ITXEXRPT.Root = "C:\\IntexReport";
                ITXEXRPT.strCompany = app.company;
                ITXEXRPT.PrintType = "OpenExcel";
            }
            Set.Merge(c11.TBMain);
            Set.Merge(c12.TBMain);
            Set.Merge(c13.TBMain);
            Set.Merge(c21.TBMain);
            Set.Merge(c22.TBMain);
            Set.Merge(c31.TBMain);
            Set.Merge(c32.TBMain);
            Set.Merge(c33.TBMain); 
            ITXEXRPT.dsSource = Set;
            ITXEXRPT.DocType = "ABCOMPARE";
            ITXEXRPT.strExcelFile = @"ITX\ITXABDOC.xls";
            string filename = (string)ITXEXRPT.WriteExcelReport();
        }
        DataSet Set = new DataSet();
        private void ClearCommand(object sender, RoutedEventArgs e)
        {
            Set = new DataSet();
             
        }
    }
}
